
/////Perceived Beneficiaries and Support for the Globalization of Higher Education: 
/// A Survey Experiment on Attitudes toward International Students
//Political Science Research and Methods
//Gift, Thomas and Lastra-Anadón, Carlos X.


clear
*ssc install estout
nobreak
cd "/Users/carlosxabel/Google Drive New/HE UK/Analysis PSRM/Final codes/"


*Data file
 use "20200107 UKsurvey.dta"

 
 



global outcvariables capforeignstudents moregovspending  biggertuitforeign prefdomestics
  
global indivcontrols female age children white bornuk somecollege unemployed incometsd incomeimp
	
//////////////
/////Main Table
//////////////
	  
	  
 
**********Table 1*************

	  	  eststo clear
   foreach var of global outcvariables  {
  quietly reg `var' heforeigntreat   $indivcontrols, r
  eststo `var'1
  
 quietly  reg `var' heforeigntreat  hetreat2  hetreat3 $indivcontrols, r
  eststo `var'2
 
 }
 
 
  esttab capforeignstudents1 capforeignstudents2, drop( female age children white bornuk somecollege unemployed incometsd incomeimp ) noconstant se r2 l  star(+ 0.10 * 0.05 ** 0.01 *** 0.001) replace
    
 ///Tex: esttab capforeignstudents1 capforeignstudents2  using "Table 1.tex", drop( female age children white bornuk somecollege unemployed incometsd incomeimp ) noconstant se r2 l  star(+ 0.10 * 0.05 ** 0.01 *** 0.001) replace
   
   
  
  
//////////////
///////Figures
///////////
  
  set scheme s2mono
  
  
   ***Figure 1
   quietly  reg capforeignstudents heforeigntreat      $indivcontrols, r
  margins, over(heforeigntreat ) post
  
    coefplot,  drop(_cons female age children white bornuk somecollege unemployed incometsd incomeimp) recast(bar) ///
  vertical xtitle(" ") graphregion(color(white)) ytitle("Probability of supporting a cap")   title(" ")   barwidth(0.5)  fcolor(*.5)   ciopts(recast(rcap)) citop ysc(r(0  .7))  ylabel(0 (.1) .7, nogrid) ///
  xlabel(1 "Control" 2 `" "Any" "Treatment" "'  ) title(" ") ///
   
   
 
 ****Figure 2
  quietly  reg capforeignstudents heforeigntreat  hetreat2   hetreat3    $indivcontrols, r
   margins, over(heforeigntreat hetreat2  hetreat3 ) post
  
    coefplot,  drop(_cons female age children white bornuk somecollege unemployed incometsd incomeimp) recast(bar) ///
  vertical xtitle(" ") graphregion(color(white)) ytitle("Probability of supporting a cap")   title(" ")   barwidth(0.5)  fcolor(*.5)   ciopts(recast(rcap)) citop ysc(r(0  .7))  ylabel(0 (.1) .7, nogrid) ///
  xlabel(1 "Control" 2 `" "Simple" "Foreign" "' 4  "Crowdout"   3 `" "Human Capital" "Flight" "') title(" ") 
   
   
   
   ****Figure 3 (By demographic subgroups)
  
   *Some College
      quietly reg capforeignstudents hetreat2##somecollege    age       female  children white bornuk  unemployed incometsd incomeimp hetreat3 controlgroup, r
  margins hetreat2, over( somecollege     ) at((means) _all) 
   marginsplot, xtitle(" ") graphregion(color(white))  ytitle(" ")  title(" ") ciopts(recast(rcap))   ylabel(0 (.1) .8, nogrid)   legend(region(lcolor(white))) xlabel(, notick) ///
 recast(scatter)  level(90)  ///
 xlabel(0 " " 1  " " ) ///
 plot(, label(  "No college"  "Some college")) xscale(range(-0.2 1.2) ) 
 graph save Graph "Somecollege.gph", replace
 
 
 * College graduate
      quietly reg capforeignstudents hetreat2##collegegraduate    age       female  children white bornuk  unemployed incometsd incomeimp hetreat3 controlgroup, r
  margins hetreat2, over( collegegraduate     ) at((means) _all) 
   marginsplot,   xtitle(" ") graphregion(color(white))  ytitle(" ")  title(" ") ciopts(recast(rcap))   ylabel(0 (.1) .8, nogrid) legend(region(lcolor(white))) xlabel(, notick)  ///
 recast(scatter)  level(90)  ///
 xlabel(0 " " 1  " " ) ///
 plot(, label(  "Not graduate"  "University graduate")) xscale(range(-0.2 1.2) )
 graph save Graph "Notcollegegraduate.gph", replace
 
 
 *Female
     quietly reg capforeignstudents hetreat2##female age  somecollege           children white bornuk  unemployed incometsd incomeimp hetreat3 controlgroup, r
  margins hetreat2, over( female     ) at((means) _all)
   marginsplot,   xtitle(" ") graphregion(color(white))    ytitle(" ")title(" ") ciopts(recast(rcap))   ylabel(0 (.1) .8, nogrid)  legend(region(lcolor(white))) xlabel(, notick) ///
 recast(scatter)  level(90)  ///
 xlabel(0 " " 1  " " ) ///
 plot(, label(  "Male"  "Female")) xscale(range(-0.2 1.2) )
 graph save Graph "Female.gph", replace
   
   
  *Children 
       quietly reg capforeignstudents hetreat2##children female age  somecollege            white bornuk  unemployed incometsd incomeimp hetreat3 controlgroup, r
  margins hetreat2, over( children     ) at((means) _all)
   marginsplot,   xtitle(" ") graphregion(color(white))   ytitle(" ")  title(" ") ciopts(recast(rcap))   ylabel(0 (.1) .8, nogrid)  legend(region(lcolor(white))) xlabel(, notick) ///
 recast(scatter)  level(90)  ///
 xlabel(0 " " 1  " " ) ///
 plot(, label(  "Not Parent"  "Parent")) xscale(range(-0.2 1.2) )
 graph save Graph "Children.gph", replace
 
 
   *White 
       quietly reg capforeignstudents hetreat2##white children female age  somecollege             bornuk  unemployed incometsd incomeimp hetreat3 controlgroup, r
  margins hetreat2, over( white     ) at((means) _all)
   marginsplot,   xtitle(" ") graphregion(color(white))  ytitle(" ")  title(" ") ciopts(recast(rcap))   ylabel(0 (.1) .8, nogrid)  legend(region(lcolor(white))) xlabel(, notick) ///
 recast(scatter)  level(90)  ///
 xlabel(0 " " 1  " " ) ///
 plot(, label(  "Non-White"  "White")) xscale(range(-0.2 1.2) )
 graph save Graph "White.gph", replace
   
   
   
     *Born UK 
       quietly reg capforeignstudents hetreat2##bornuk white children female age  somecollege               unemployed incometsd incomeimp hetreat3 controlgroup, r
  margins hetreat2, over( bornuk     ) at((means) _all)
   marginsplot,   xtitle(" ") graphregion(color(white))  ytitle(" ") title(" ") ciopts(recast(rcap))   ylabel(0 (.1) .8, nogrid)  legend(region(lcolor(white))) xlabel(, notick) ///
 recast(scatter)  level(90)  ///
 xlabel(0 " " 1  " " ) ///
 plot(, label(  "Not born in UK"  "Born in UK")) xscale(range(-0.2 1.2) )
 graph save Graph "BornUK.gph", replace
   
   
      *Unemployed
       quietly reg capforeignstudents hetreat2##unemployed bornuk white children female age  somecollege                incometsd incomeimp hetreat3 controlgroup, r
  margins hetreat2, over( unemployed     ) at((means) _all)
   marginsplot,   xtitle(" ") graphregion(color(white)) ytitle(" ")  ytitle(" ")  title(" ") ciopts(recast(rcap))   ylabel(0 (.1) .8, nogrid)  legend(region(lcolor(white))) xlabel(, notick) ///
 recast(scatter)  level(90)  ///
 xlabel(0 " " 1  " " ) ///
 plot(, label(  "Employed"  "Not employed")) xscale(range(-0.2 1.2) )
 graph save Graph "Unemployed.gph", replace
 
 
 
   *Income
       quietly reg capforeignstudents hetreat2##abovemedincome bornuk white children female age  somecollege          hetreat3 controlgroup, r
  margins hetreat2, over( abovemedincome     ) at((means) _all)
   marginsplot,   xtitle(" ") graphregion(color(white)) ytitle(" ")  ytitle(" ")  title(" ") ciopts(recast(rcap))   ylabel(0 (.1) .8, nogrid)  legend(region(lcolor(white))) xlabel(, notick) ///
 recast(scatter)  level(90)  ///
 xlabel(0 " " 1  " " ) ///
 plot(, label(  "Low income"  "High income")) xscale(range(-0.2 1.2) )
 graph save Graph "Income.gph", replace
 
 *Brexiteer
      quietly reg capforeignstudents hetreat2##brexiteer brexitneutral unemployed bornuk white children female age  somecollege                incometsd incomeimp hetreat3 controlgroup, r
  margins hetreat2, over( brexiteer     ) at((means) _all)
   marginsplot,   xtitle(" ") graphregion(color(white))  ytitle(" ") title(" ") ciopts(recast(rcap))   ylabel(0 (.1) .8, nogrid) legend(region(lcolor(white))) xlabel(, notick) ///
 recast(scatter)  level(90)  ///
 xlabel(0 " " 1  " " ) ///
 plot(, label(  "Brexit remainer"  "Brexit leaver")) xscale(range(-0.2 1.2) )
 graph save Graph "Brexiteer.gph", replace
 
 
 *Conservative
      quietly reg capforeignstudents hetreat2##conservative  unemployed bornuk white children female age  somecollege                incometsd incomeimp hetreat3 controlgroup, r
  margins hetreat2, over( conservative     ) at((means) _all)
   marginsplot,   xtitle(" ") graphregion(color(white))  ytitle(" ") title(" ") ciopts(recast(rcap))   ylabel(0 (.1) .8, nogrid) legend(region(lcolor(white))) xlabel(, notick) ///
 recast(scatter)  level(90)  ///
 xlabel(0 " " 1  " " ) ///
 plot(, label(  "Non-Conservative"  "Conservative")) xscale(range(-0.2 1.2) )
 graph save Graph "Conservative.gph", replace
  
  *Immigration exposure
       quietly reg capforeignstudents hetreat2##abovemdmigration bornuk white children female age  somecollege       incometsd incomeimp   hetreat3 controlgroup, r
  margins hetreat2, over( abovemdmigration     ) at((means) _all)
   marginsplot,   xtitle(" ") graphregion(color(white)) ytitle(" ")  ytitle(" ")  title(" ") ciopts(recast(rcap))   ylabel(0 (.1) .8, nogrid)  legend(region(lcolor(white))) xlabel(, notick) ///
 recast(scatter)  level(90)  ///
 xlabel(0 " " 1  " " ) ///
 plot(, label( "Low imm."  "High imm."  )) xscale(range(-0.2 1.2) )
 graph save Graph "Immigration.gph", replace
 
 
 *Old
 
       quietly reg capforeignstudents hetreat2##agegroup6 bornuk white children female age  somecollege       incometsd incomeimp hetreat3 controlgroup, r
  margins hetreat2, over( abovemdmigration     ) at((means) _all)
   marginsplot,   xtitle(" ") graphregion(color(white)) ytitle(" ")  ytitle(" ")  title(" ") ciopts(recast(rcap))   ylabel(0 (.1) .8, nogrid)  legend(region(lcolor(white))) xlabel(, notick) ///
 recast(scatter)  level(90)  ///
 xlabel(0 " " 1  " " ) ///
 plot(, label( "Below 65"  "Over 65"  )) xscale(range(-0.2 1.2) )
 graph save Graph "Old.gph", replace
 
 
 *Young
 *gen below30=1 if age<=30
 *replace below30=0 if age>30
 
 
        quietly reg capforeignstudents hetreat2##below30 bornuk white children female age  somecollege       incometsd incomeimp hetreat3 controlgroup, r
  margins hetreat2, over( abovemdmigration     ) at((means) _all)
   marginsplot,   xtitle(" ") graphregion(color(white)) ytitle(" ")  ytitle(" ")  title(" ") ciopts(recast(rcap))   ylabel(0 (.1) .8, nogrid)  legend(region(lcolor(white))) xlabel(, notick) ///
 recast(scatter)  level(90)  ///
 xlabel(0 " " 1  " " ) ///
 plot(, label( "Over 30"  "Below 30"  )) xscale(range(-0.2 1.2) )
 graph save Graph "Young.gph", replace
 
 
   graph combine "Female.gph" "White.gph" "BornUK.gph" "Children.gph"  "Notcollegegraduate.gph" "Income.gph"  "Unemployed.gph"  "Brexiteer.gph" "Conservative.gph" "Immigration.gph" "Old.gph" "Young.gph", col(3) 
 
   
  
		
		
//////////////////		
//////////Appendix Materials//////////
/////////////////////////////

**** Table A2**
	*Balance tables and comparison with UK averages (column 0 is imputed manually)
		  balancetable (mean if hetreatall==0)   (mean if hetreatall==1) (diff hetreat1 if (hetreatall!=2 & hetreatall!=3) ) (mean if hetreatall==2) (diff hetreat2 if hetreatall!=1 & hetreatall!=3 ) ///
   (mean if hetreatall==3) (diff hetreat3 if hetreatall!=1 & hetreatall!=2 ) ///
  female white age children  bornuk collegegraduate unemployed incometsd incomeimp conservative brexiteer  tenyearmigrationpct using "balancetable2.tex", replace


  
  
  	 * Table A3 (no covariates)
	 eststo clear
  foreach var of global outcvariables  {
  quietly reg `var' heforeigntreat   , r
  eststo `var'1
  
 quietly  reg `var' heforeigntreat  hetreat2  hetreat3 , r
  eststo `var'2
 
 }

   esttab capforeignstudents1 capforeignstudents2 ,  noconstant se r2 l  star(+ 0.10 * 0.05 ** 0.01 *** 0.001) replace

 
///Tex:  esttab capforeignstudents1 capforeignstudents2  using "App Table A3 No covariates.tex",  noconstant se r2 l  star(+ 0.10 * 0.05 ** 0.01 *** 0.001) replace

  
  

 ******** Table A4 (probit)
   eststo clear
 
  quietly probit capforeignstudents heforeigntreat   $indivcontrols, r
  eststo capforeignstudents1
  
 quietly  probit capforeignstudents heforeigntreat  hetreat2  hetreat3 $indivcontrols, r
  eststo capforeignstudents2
 
 
  esttab capforeignstudents1 capforeignstudents2  , drop( female age children white bornuk somecollege unemployed incometsd incomeimp ) noconstant se r2 l  star(+ 0.10 * 0.05 ** 0.01 *** 0.001) replace
    
	
 ///Tex: esttab capforeignstudents1 capforeignstudents2  using "App Table 1 LPM.tex", drop( female age children white bornuk somecollege unemployed incometsd incomeimp ) noconstant se r2 l  star(+ 0.10 * 0.05 ** 0.01 *** 0.001) replace
    
	

  
  
  ***Table A5 Post stratification weights
  	  	  eststo clear
   foreach var of global outcvariables  {
  quietly reg `var' heforeigntreat   $indivcontrols [iw=unemployweight], r
  eststo `var'1
  
 quietly  reg `var' heforeigntreat  hetreat2  hetreat3 $indivcontrols [iw=unemployweight], r
  eststo `var'2
 
 }

 
   esttab capforeignstudents1 capforeignstudents2  , drop( female age children white bornuk somecollege unemployed incometsd incomeimp ) noconstant se r2 l  star(+ 0.10 * 0.05 ** 0.01 *** 0.001) replace
   		
 ///Tex: esttab capforeignstudents1 capforeignstudents2  using "Table PostWeights.tex", drop( female age children white bornuk somecollege unemployed incometsd incomeimp ) noconstant se r2 l  star(+ 0.10 * 0.05 ** 0.01 *** 0.001) replace
   		
	

  

****** Table A6 (with context and political covariates)
global addedvariables  brexiteer brexitneutral conservative tenyearmigrationpct
 	  	  eststo clear
   foreach var of global outcvariables  {
  quietly reg `var' heforeigntreat   $indivcontrols $addedvariables, r
  eststo `var'1
  
 quietly  reg `var' heforeigntreat  hetreat2  hetreat3 $indivcontrols $addedvariables, r
  eststo `var'2
 
 }
 
 
  esttab capforeignstudents1 capforeignstudents2 , drop( female age children white bornuk somecollege unemployed incometsd incomeimp ) noconstant se r2 l  star(+ 0.10 * 0.05 ** 0.01 *** 0.001) replace
  
  
///Tex:  esttab capforeignstudents1 capforeignstudents2  using "Table 1polvars.tex", drop( female age children white bornuk somecollege unemployed incometsd incomeimp ) noconstant se r2 l  star(+ 0.10 * 0.05 ** 0.01 *** 0.001) replace 

  
  
  
 *******Table A7 Total effects
  reg capforeignstudents hetreat1 hetreat2 hetreat3 $indivcontrols, r
  eststo totaleffects
  
  reg capforeignstudents controlgroup hetreat1 hetreat3  $indivcontrols, r
  eststo comparemarginals
   
  
     esttab totaleffects comparemarginals  , title("Support for cap on foreign students, total effects by treatment group") drop( female age children white bornuk somecollege unemployed incometsd incomeimp ) noconstant se r2 l  star(+ 0.10 * 0.05 ** 0.01 *** 0.001) append
 
  
  
  
 ///Tex: esttab totaleffects comparemarginals   using "Totaleffects.tex", title("Support for cap on foreign students, total effects by treatment group") drop( female age children white bornuk somecollege unemployed incometsd incomeimp ) noconstant se r2 l  star(+ 0.10 * 0.05 ** 0.01 *** 0.001) append
 
  
 ******Table A8 (STEM and culturally distant)
  eststo clear
  
   foreach var of global outcvariables  {
  quietly reg `var' heforeigntreat  hetreat2  hetreat3 $indivcontrols, r
  eststo `var'
  
  quietly reg `var' heforeigntreat hetreat2 hetreat2distant hetreat3 hetreat3highva   $indivcontrols, r
  eststo `var'inter
  }
  
  esttab capforeignstudents capforeignstudentsinter , drop( female age children white bornuk somecollege unemployed incometsd incomeimp ) noconstant noconstant se r2 l  star(+ 0.10 * 0.05 ** 0.01 *** 0.001) append
  
  
 ///Tex: esttab capforeignstudents1 capforeignstudentsinter using "effectallvariablescontrol4.tex", drop( ) noconstant se r2 l  star(+ 0.10 * 0.05 ** 0.01 *** 0.001) append


  
   
   ********Table A9  (Crowdout analysis by subgroup)
   
   eststo clear
   
   foreach var in female  white children bornuk collegegraduate unemployed  conservative brexiteer {
   	     quietly reg capforeignstudents hetreat2##`var' bornuk white children female age  somecollege       incometsd incomeimp        hetreat3 controlgroup, r
	
	eststo
   }
   
   
     quietly reg capforeignstudents c.hetreat2##c.age bornuk white children female age  somecollege       incometsd incomeimp       hetreat3 controlgroup, r
	eststo
   
   quietly reg capforeignstudents c.hetreat2##c.incometsd bornuk white children female age  somecollege       incometsd incomeimp         hetreat3 controlgroup, r
	eststo
	
	   quietly reg capforeignstudents c.hetreat2##c.tenyearmigrationpct bornuk white children female age  somecollege       incometsd incomeimp      hetreat3 controlgroup, r
	eststo

	
	  esttab est1 est2 est3 est4 est5 est6 , drop( ) noconstant se r2 l  star(+ 0.10 * 0.05 ** 0.01 *** 0.001) replace
  
    esttab est7 est8 est9 est10 est11   , drop(  ) noconstant se r2 l  star(+ 0.10 * 0.05 ** 0.01 *** 0.001) replace
	
///Tex:  esttab est1 est2 est3 est4 est5 est6 using "CrowdoutOLSSubgroups.tex", drop( ) noconstant se r2 l  star(+ 0.10 * 0.05 ** 0.01 *** 0.001) replace
  
 ///Tex:   esttab est7 est8 est9 est10 est11   using "CrowdoutOLS2Subgroups2.tex", drop(  ) noconstant se r2 l  star(+ 0.10 * 0.05 ** 0.01 *** 0.001) replace
	  	
		
	*******Table A10 for HC flight analysis by subgroup	
		
   eststo clear
   foreach var in female  white children bornuk collegegraduate unemployed  conservative brexiteer {
   	     quietly reg capforeignstudents hetreat3##`var' bornuk white children female age  somecollege       incometsd incomeimp         hetreat2 controlgroup , r
	
	eststo
   }
   
   
     quietly reg capforeignstudents c.hetreat3##c.age bornuk white children female age  somecollege       incometsd incomeimp         hetreat2 controlgroup , r
	eststo
   
   quietly reg capforeignstudents c.hetreat3##c.incometsd bornuk white children female age  somecollege       incometsd incomeimp         hetreat2 controlgroup , r
	eststo
	
	   quietly reg capforeignstudents c.hetreat3##c.tenyearmigrationpct bornuk white children female age  somecollege       incometsd incomeimp        hetreat2 controlgroup , r
	eststo

	
	  esttab est1 est2 est3 est4 est5 est6, drop( ) noconstant se r2 l  star(+ 0.10 * 0.05 ** 0.01 *** 0.001) replace
  
    esttab est7 est8 est9 est10 est11  , drop(  ) noconstant se r2 l  star(+ 0.10 * 0.05 ** 0.01 *** 0.001) replace
		
	
	
 ///Tex: esttab est1 est2 est3 est4 est5 est6 using "HCFlightOLSSubgroups.tex", drop( ) noconstant se r2 l  star(+ 0.10 * 0.05 ** 0.01 *** 0.001) replace
  
 ///Tex:   esttab est7 est8 est9 est10 est11   using "HCFlightOLS2Subgroups2.tex", drop(  ) noconstant se r2 l  star(+ 0.10 * 0.05 ** 0.01 *** 0.001) replace
		
		
  
		
